home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Essentials / MacApp Documentation / MacApp AppleLink Messages / MacApp.Tech$ 12⁄22⁄89 / 0242-Associating Two File-Dec89 < prev    next >
Encoding:
Text File  |  1989-12-22  |  2.7 KB  |  77 lines  |  [TEXT/GEOL]

  1. Item    7145868                         21-Dec-89        08:03
  2.  
  3. From:   D5369                           Mgmt Sys Des, Chuck McMath,PRT
  4.  
  5. To:     MACAPP.TECH$                    MacApp Technical
  6.  
  7. Sub:    Associating Two Files - How?
  8.  
  9. I am writing an MacApp application which creates documents that refer to other
  10. documents.  For instance, say Document A refers to Document B.  What parameters
  11. can I store in DocA that will enable me to open DocB when DocA is opened?
  12.  
  13. My _current_ guess is the following are the minimum parameters necessary to
  14. locate a file: 1. the volume name, 2. the file name (DocB's name in this case),
  15. and 3. the directory ID where DocB resides.  I initially tried using the file
  16. name and its vRefNum, but have discovered that vRefNums can change from time to
  17. time, and I lose track of my documents.
  18.  
  19. Unfortunately, I am still having trouble reopening my associated documents.
  20. For instance, I open DocA, my application looks and sees that DocB is not open.
  21. If the user wants to open DocB then I try to, and fail (with a -43 OSErr in
  22. ReadFromFile).  TMyApp.OpenOld checks docs of type A when they are opened, and
  23. if their DocBs are not around, calls OpenOtherDoc, which does the following (a
  24. FileIDRec is defined as:
  25.  
  26.         FileIDRec = RECORD
  27.                     volName:    Str255; { volume where file is stored }
  28.                     name:       Str255; { name of the file }
  29.                     dirID:      LongInt;{ the file's directory ID }
  30.                 END;)
  31.  
  32. PROCEDURE TMyApp.OpenOtherDoc(theIDRec: FileIDRec);
  33. VAR
  34.     theAppFile:AppFile;
  35.     theVolRec: WDPBRec;
  36.     tempStr:   Str255;
  37.     tempVRefNum:   INTEGER;
  38.     tempStr2:  Str255;
  39.     theVRefNum:INTEGER;
  40. BEGIN
  41.     FailOSErr(GetVol(@tempStr, tempVRefNum));
  42.     FailOSErr(SetVol(@theIDRec.volName, 0));
  43.     FailOSErr(GetVol(@tempStr2, theVRefNum));
  44.  
  45.     WITH theVolRec DO
  46.         BEGIN
  47.         ioCompletion := NIL;
  48.         ioNamePtr := NIL;
  49.         ioVRefNum := theVRefNum;
  50.         ioWDDirID := theIDRec.dirID;
  51.     END;
  52.  
  53.     FailOSErr(PBHSetVol(@theVolRec, FALSE));
  54.     FailOSErr(GetVol(@tempStr2, theVRefNum));
  55.  
  56.     WITH theAppFile DO
  57.         BEGIN
  58.         vRefNum := theVRefNum;
  59.         fType := kOtherFileType;
  60.         versNum := 0;
  61.         fName := theIDRec.name;
  62.     END;
  63.  
  64.     OpenOld(cOpenOtherDoc, theAppFile);
  65. END;   { TMyApp.OpenOtherDoc }
  66.  
  67. The problem is that OpenOld fails in ReadFromFile with a -43 error (file not
  68. found), so I am obviously not setting the directory correctly.  Since OpenOld's
  69. only file parameter is an AppFile record, I need to pass the file name (which I
  70. have) and the file vRefNum (which I can't seem to get).
  71.  
  72. Any clues anyone?
  73.  
  74. By the way, I'm not yet on MACAPP.TECH$, so please link any responses to my
  75. account.  Thanks in advance, fellow MacApp'ers…
  76.  
  77.